//
//  LWProxyProfileCtrl.m
//  laowu
//
//  Created by Northwan on 15/5/6.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//  代理公司

#import "LWProxyProfileCtrl.h"
#import "ProxyProfileResult.h"

@interface LWProxyProfileCtrl ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *headImgView;
@property (weak, nonatomic) IBOutlet UILabel *positionNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *companyNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *companyManagerNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressAreaLabel;
@property (weak, nonatomic) IBOutlet UILabel *proxyNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *proxyPhoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *proxyWechatLabel;
@property (weak, nonatomic) IBOutlet UILabel *proxyQQLabel;
@property (weak, nonatomic) IBOutlet UILabel *proxyProvinceLabel;
@property (weak, nonatomic) IBOutlet UILabel *proxyCityLabel;
@property (weak, nonatomic) IBOutlet UILabel *proxyLevelLabel;
@property (weak, nonatomic) IBOutlet UILabel *pushNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *pushPhoneLabel;

@end

@implementation LWProxyProfileCtrl

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setTitle:@"个人资料"];
    [self.scrollView setAlwaysBounceVertical:YES];
    CALayer *layer=[self.headImgView layer];
    [layer setCornerRadius:self.headImgView.width/2];
    [layer setMasksToBounds:YES];
    [layer setBorderWidth:2];
    [layer setBorderColor:[[UIColor whiteColor] CGColor]];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self getData];
}

-(void)getData{
    MBProgressHUD *lodingView =  [DialogUtils showLoadingWithView:self.view];
    [MeDataTool getProxyProfile:^(ProxyProfileRes *result) {
        [lodingView hide:YES];
        if(result.isSucc){
            [self initData:result];
        }else{
            [DialogUtils showTipsWithView:self.view String:result.msg];
        }
    } failure:^(NSError *error) {
        [lodingView hide:YES];
        [DialogUtils showTipsWithView:self.view String:@"加载失败"];
    }];
}

-(void)initData:(ProxyProfileRes*)result{
    ProxyProfileResult *res = result.datas;
    [_headImgView sd_setImageWithURL:[NSURL URLWithString:res.user_img] placeholderImage:[UIImage imageNamed:@"headavatar"]];
    [_positionNameLabel setText:res.group_name];
    [_companyNameLabel setText:res.d_org_name];
    [_companyManagerNameLabel setText:res.d_corporate];
    [_addressAreaLabel setText:res.d_area];
    [_proxyNameLabel setText:res.d_people];
    [_proxyPhoneLabel setText:res.d_phone];
    [_proxyWechatLabel setText:res.d_wx];
    [_proxyQQLabel setText:res.d_qq];
    [_proxyProvinceLabel setText:res.d_sheng_fen];
    [_proxyCityLabel setText:res.d_shi_fen];
    [_proxyLevelLabel setText:res.d_level];
}

@end
